/**
 * <p>Title: ServiceZMCEC0.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 张志芳
 * @version 1.0
 * <pre>Histroy:
 *          2011-12-23 下午04:43:27  张志芳  Create
 *</pre>
 */
package com.baosight.sczx.zm.ce.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baosight.iplat4j.core.ei.EiBlockMeta;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.ef.ui.tree.TreeConstants;
import com.baosight.iplat4j.ef.ui.tree.TreeService;

/**
 * 设备卡片树结构
 * <p>Title: ServiceZMCEC0.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 张志芳
 * @version 1.0
 * <pre>Histroy:
 *          2011-12-23 下午04:43:27  张志芳  Create
 *</pre>
 */
public class ServiceZMCEC0 extends TreeService {
	private String fdKeyId = "root0";//设置根节点默认主键的值
	/**
	 * <p>Function: getChildNodes</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCE11</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-4-14上午09:06:08 张志芳
	 * </p>
	 *
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
	public List getChildNodes(String arg0) {
		Map _argMap = new HashMap();
		_argMap.put(TreeConstants.TREE_NODE, arg0);
		List<Map> childNodes = dao.query("ZMCEEquipmentClass.queryChildrenCode", _argMap);
		for(Map map:childNodes)
		{
			String text=map.get("text").toString();
			map.put("showText", "(" + map.get("code") + ")" + text);
		}
		return childNodes;
	}

	/**
	 * <p>Function: getTopNodes</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCE11</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-4-14上午09:06:08 张志芳
	 * </p>
	 *
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
	public List getTopNodes() {
		Map _argMap = new HashMap();
		_argMap.put("topNode", fdKeyId);
		List<Map> childNodes = dao.query("ZMCEEquipmentClass.queryChildrenCode", _argMap);
		for(Map map:childNodes)
		{
			map.put("showText", map.get("text"));
		}
		return childNodes;
	}

	/**
	 * <p>Function: initMetaData</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCE11</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-4-14上午09:06:08 张志芳
	 * </p>
	 *
	 */
	@Override
	public EiBlockMeta initMetaData() {
		EiBlockMeta eiMetadata = new EiBlockMeta();

		EiColumn eiColumn = new EiColumn("label");
		eiColumn.setDescName("FD_KEY_ID");
		eiColumn.setNullable(false);
		eiColumn.setPrimaryKey(false);
		eiMetadata.addMeta(eiColumn);

		eiColumn = new EiColumn("showText");
		eiColumn.setDescName("名称");
		eiColumn.setNullable(false);
		eiColumn.setPrimaryKey(false);
		eiMetadata.addMeta(eiColumn);
		
		eiColumn = new EiColumn("text");
		eiColumn.setDescName("名称");
		eiColumn.setNullable(false);
		eiColumn.setPrimaryKey(false);
		eiMetadata.addMeta(eiColumn);

		eiColumn = new EiColumn("toencode");
		eiColumn.setDescName("内码");
		eiColumn.setNullable(false);
		eiColumn.setPrimaryKey(false);
		eiMetadata.addMeta(eiColumn);
		
		eiColumn = new EiColumn("code");
		eiColumn.setDescName("编码");
		eiColumn.setNullable(false);
		eiColumn.setPrimaryKey(false);
		eiMetadata.addMeta(eiColumn);		
		
		eiColumn = new EiColumn("leaf");
		eiColumn.setDescName("是否叶子");
		eiColumn.setType(EiConstant.COLUMN_TYPE_NUMBER);
		eiColumn.setNullable(false);
		eiColumn.setPrimaryKey(false);
		eiMetadata.addMeta(eiColumn);
		return eiMetadata;
	}


}
